value->texture_id = gsk_gl_driver_create_texture (driver, width, height);
gsk_gl_driver_bind_source_texture (driver, value->texture_id);
- gsk_gl_driver_init_texture_empty (driver, value->texture_id, GL_NEAREST, GL_NEAREST);
+ gsk_gl_driver_init_texture_empty (driver, value->texture_id, GL_LINEAR, GL_LINEAR);
value->tx = 0.0f;
value->ty = 0.0f;
value->th = 1.0f;
}
-
upload_glyph (key, value);
}
-#define PHASE(x) ((x % PANGO_SCALE) * 4 / PANGO_SCALE)
+#define PHASE(x) ((int)(floor (4 * (x + 0.125)) - 4 * floor (x + 0.125)))
gboolean
gsk_gl_glyph_cache_lookup (GskGLGlyphCache *cache,
PangoFont *font,
PangoGlyph glyph,
- int x,
- int y,
+ float x,
+ float y,
float scale,
GskGLDriver *driver,
GskGLCachedGlyph *cached_glyph_out)
GskGLCachedGlyph *value;
guint xshift = PHASE (x);
guint yshift = PHASE (y);
+ const guint key_scale = (guint)(scale * 1024);
value = g_hash_table_lookup (cache->hash_table,
&(GlyphCacheKey) {
.glyph = glyph,
.xshift = xshift,
.yshift = yshift,
- .scale = (guint)(scale * 1024)
+ .scale = key_scale
});
if (value)
{
GlyphCacheKey *key;
PangoRectangle ink_rect;
- const guint key_scale = (guint)(scale * 1024);
pango_font_get_glyph_extents (font, glyph, &ink_rect, NULL);
pango_extents_to_pixels (&ink_rect, NULL);
key->glyph = glyph;
key->xshift = xshift;
key->yshift = yshift;
- key->scale = key_scale;
+ key->scale = key_scale;
if (key->scale > 0 &&
- ink_rect.width * key->scale > 0 &&
- ink_rect.height * key->scale > 0)
+ value->draw_width * key->scale / 1024 > 0 &&
+ value->draw_height * key->scale / 1024 > 0)
add_to_cache (cache, key, driver, value);
*cached_glyph_out = *value;
if (gi->glyph == PANGO_GLYPH_EMPTY)
continue;
+ cx = (double)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
+ cy = (double)(gi->geometry.y_offset) / PANGO_SCALE;
+
gsk_gl_glyph_cache_lookup (self->glyph_cache,
(PangoFont *)font,
gi->glyph,
- x * PANGO_SCALE + x_position + gi->geometry.x_offset,
-+ y * PANGO_SCALE + gi->geometry.y_offset,
+ x + cx,
++ y + cy,
text_scale,
self->gl_driver,
&glyph);
if (glyph.texture_id == 0)
goto next;
- cx = (x_position + gi->geometry.x_offset) / PANGO_SCALE;
- cy = gi->geometry.y_offset / PANGO_SCALE;
-
ops_set_texture (builder, glyph.texture_id);
tx = glyph.tx;
tx2 = tx + glyph.tw;
ty2 = ty + glyph.th;
- glyph_x = x + cx + glyph.draw_x;
- glyph_y = y + cy + glyph.draw_y;
+ glyph_x = floor (x + cx + 0.125) + glyph.draw_x;
+ glyph_y = floor (y + cy + 0.125) + glyph.draw_y;
glyph_w = glyph.draw_width;
glyph_h = glyph.draw_height;